﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Omes.Services;

namespace Omes.Admin
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string back = Request.QueryString["back"];
            if (!string.IsNullOrEmpty(back))
            {
                if (back == "submit")
                {
                    string userName = LoginName.Text;
                    string password = Password.Text;
                    DbServer db = new DbServer();
                    if (db.CheckUser(userName, password))
                    {
                        System.Web.Security.FormsAuthentication.SetAuthCookie(userName, false);
                        Session["omesuser"] = userName;
                        Response.Redirect("~/SystemInfo/SystemDesktop.aspx");
                    }
                    else
                    {
                        errorShow.Text = "用户名或密码错误";
                    }
                }
                else if(back=="refresh")
                {
                    LoginName.Text = "";
                    Password.Text = "";
                }
            }
        }

    }
}